﻿<phone:PhoneApplicationPage
    x:Class="SkiTracker.View.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:converter="clr-namespace:SkiTracker.Converter" xmlns:util="clr-namespace:SkiTracker.Controls"
    xmlns:behavior="clr-namespace:SkiTracker.Behavior"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="True">
    <phone:PhoneApplicationPage.Resources>
        <converter:BoolenToOpacityConverter x:Key="BoolenToOpacityConverter" />
        <Style x:Key="TileButtonStyle" TargetType="Button">
        	<Setter Property="Background" Value="{StaticResource PhoneAccentBrush}"/>
        	<Setter Property="BorderBrush" Value="{StaticResource PhoneForegroundBrush}"/>
        	<Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
        	<Setter Property="BorderThickness" Value="{StaticResource PhoneBorderThickness}"/>
        	<Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilySemiBold}"/>
        	<Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMedium}"/>
            <Setter Property="BorderThickness" Value="0"/>
        	<Setter Property="Padding" Value="10,5,10,6"/>
        	<Setter Property="Template">
        		<Setter.Value>
        			<ControlTemplate TargetType="Button">
        				<Grid x:Name="grid" Background="Transparent" Opacity="0.4">
        					<VisualStateManager.VisualStateGroups>
        						<VisualStateGroup x:Name="CommonStates">
        							<VisualState x:Name="Normal"/>
        							<VisualState x:Name="MouseOver">
        								<Storyboard>
        									<DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="grid" d:IsOptimized="True"/>
        								</Storyboard>
        							</VisualState>
        							<VisualState x:Name="Pressed">
        								<Storyboard>
        									<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentContainer">
        										<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneButtonBasePressedForegroundBrush}"/>
        									</ObjectAnimationUsingKeyFrames>
        									<DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="grid" d:IsOptimized="True"/>
        								</Storyboard>
        							</VisualState>
        							<VisualState x:Name="Disabled">
        								<Storyboard>
        									<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentContainer">
        										<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneDisabledBrush}"/>
        									</ObjectAnimationUsingKeyFrames>
        									<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="ButtonBackground">
        										<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneDisabledBrush}"/>
        									</ObjectAnimationUsingKeyFrames>
        								</Storyboard>
        							</VisualState>
        						</VisualStateGroup>
        						<VisualStateGroup x:Name="FocusStates"/>
        					</VisualStateManager.VisualStateGroups>
        					<Border x:Name="ButtonBackground" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="0" Margin="{StaticResource PhoneTouchTargetOverhang}">
        						<ContentControl x:Name="ContentContainer" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Foreground="{TemplateBinding Foreground}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
        					</Border>
        				</Grid>
        			</ControlTemplate>
        		</Setter.Value>
        	</Setter>
        </Style>
    </phone:PhoneApplicationPage.Resources>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <Image Source="../Assets/Background.jpg" Stretch="Fill" Grid.RowSpan="2" Opacity=".6"/>
        
        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock Text="Ski-Tracker" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0" 
              util:GridUtilities.RowDefinitions="Auto, *, Auto" >
           

            <Grid x:Name="Login"
                  util:GridUtilities.RowDefinitions="Auto, Auto, Auto" 
                  util:GridUtilities.ColumnDefinitions="Auto, *">

                <TextBlock Text="Name" Grid.Column="0" Grid.Row="0" VerticalAlignment="Center" Margin="12"/>
                <TextBox Text="{Binding Device.Name, Mode=TwoWay}" Grid.Column="1"  Grid.Row="0" IsEnabled="{Binding IsInitialized}"/>
                <TextBlock Text="Gruppe" Grid.Column="0" Grid.Row="1" VerticalAlignment="Center" Margin="12"/>
                <TextBox Text="{Binding Device.GroupName, Mode=TwoWay}" Grid.Column="1"  Grid.Row="1" IsEnabled="{Binding IsInitialized}"/>
                <TextBlock Text="Id" Grid.Column="0" Grid.Row="2" VerticalAlignment="Center" Margin="12"/>
                <TextBlock  Text="{Binding Device.Id}" Grid.Column="0" Grid.Row="2" VerticalAlignment="Center" Margin=" 54 0 0 0" Tap="Id_OnTap"/>
                <Button Grid.Column="1" Grid.Row="2" Content="Speichern" Command="{Binding SaveCommand}"/>

            </Grid>

            <Grid Grid.Row="1" Margin="12 12 12 0" VerticalAlignment="Top"
                  util:GridUtilities.RowDefinitions="*, *, Auto"
                  util:GridUtilities.ColumnDefinitions="*, *">

                <Button Command="{Binding NavigateToCommand}" CommandParameter="TrackPosition"
                        x:Name="Track"
                        Opacity="{Binding IsDeviceRegisterd, Converter={StaticResource BoolenToOpacityConverter}}"
                        Grid.Row="0" Grid.Column="0" Style="{StaticResource TileButtonStyle}">
                    <Image Source="..\Assets\MainPageTiles\GpsTile.png" />
                </Button>

                <Button Command="{Binding NavigateToCommand}" CommandParameter="ShowFriends" 
                        x:Name="Locate"
                        Opacity="{Binding IsDeviceRegisterd, Converter={StaticResource BoolenToOpacityConverter}}"
                        Grid.Row="0" Grid.Column="1" Style="{StaticResource TileButtonStyle}">
                    <Image Source="..\Assets\MainPageTiles\MapTile.png"/>
                </Button>

                <Button Command="{Binding NavigateToCommand}" CommandParameter="Conversation" 
                        x:Name="Messaging"
                        Opacity="{Binding IsDeviceRegisterd, Converter={StaticResource BoolenToOpacityConverter}}"
                        Grid.Row="1" Grid.ColumnSpan="2" Style="{StaticResource TileButtonStyle}">
                    <Image Source="..\Assets\MainPageTiles\MessageTile.png" Width="388" Height="173"/>
                </Button>
            </Grid>

            <TextBlock Text="© Thomas Mutzl" 
                           Grid.Row="2" Grid.ColumnSpan="2" VerticalAlignment="Bottom"
                           TextAlignment="Center" FontSize="30" Margin="12"/>
        </Grid>

    </Grid>

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar Mode="Minimized" Opacity="1.0" IsMenuEnabled="True" IsVisible="True" >
            <shell:ApplicationBarIconButton Click="_1_Click" IconUri="/Assets/AppBar/1.png" Text="Anmelden" />
            <shell:ApplicationBarIconButton Click="_2_Click" IconUri="/Assets/AppBar/2.png" Text="Tracking" IsEnabled="False" />
            <shell:ApplicationBarIconButton Click="_3_Click" IconUri="/Assets/AppBar/3.png" Text="Locate" IsEnabled="False"/>
            <shell:ApplicationBarIconButton Click="_4_Click"  IconUri="/Assets/AppBar/4.png" Text="Messaging" IsEnabled="False"/>
            <!--<shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Click="_1_Click" Text="Anmelden (mobile service)" />
                <shell:ApplicationBarMenuItem Click="_2_Click" Text="Tracking (geo, map, livetile)" IsEnabled="False" />
                <shell:ApplicationBarMenuItem Click="_3_Click" Text="Locate (server-script)" IsEnabled="False"/>
                <shell:ApplicationBarMenuItem Click="_4_Click" Text="Messaging (mpns)" IsEnabled="False"/>
            </shell:ApplicationBar.MenuItems>-->
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>